package com.itcast.springboot.mapper;

import com.itcast.springboot.bean.User;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserMapper {

    //增
    public Integer insertUser(User user);

    //实现批量插入
    public Integer insertUsers(List<User> users);

    //删
    public Integer deleteUser(String uid);
    //查

    //通过id查询
    public User getUserById(String uid);

    //查询所有
    public List<User> getUsers();

    //通过id查询user和userDyna
    public User getUserAndDynaById(String uid);

    //通过id查询出user和对应的friends列表
    public User getUserAndFriendsById(String uid);

    //使用分步查询和延迟查询实现查询user，按是否需要查询userDyna
    public User getUserAndDynaByIdStep(String uid);

    //使用分步查询和延迟查询实现查询users，按是否需要查询userDyna
    public List<User> getUsersAndDynaByIds(@Param("uids") List<String> uids);

    //使用分页查询查询所有
    public List<User> getUsersPage();

    //in查询：多个id获取多个用户信息
    public List<User> getUsersByIds(@Param("uids") List<String> uids);

    //查询头像
//    public String getAvatarUrlById(@Param("uid") Integer uid);
    //通过uid查询姓名
    public String getUsernameById(@Param("uid") String uid);

    //通过username模糊查询和gender进行查询
    public List<User> getUsersByUsernameAndGender(@Param("username") String username, @Param("gender") Integer gender);

    //改
    public Integer updateUser(User user);
    //修改头像
//    public Integer updateAvatarUrl(@Param("uid") Integer uid, @Param("avatarUrl") String headPhoto);
}
